from flask import Flask
from flask_restful import Api, Resource, marshal_with, fields

app = Flask(__name__)

api = Api(app)


class Article:
    def __init__(self, username, content):
        self.username = username
        self.content = content


article = Article('李大宝'.decoding('utf8').encoding('utf8'), '这是李大宝的程序')


class LoginView(Resource):
    resource_fields = {
        'username': fields.String,
        'content': fields.String
    }

    @marshal_with(resource_fields)
    def get(self):
        # return {'username': 'hello world'}
        return article


api.add_resource(LoginView, '/login')

if __name__ == '__main__':
    app.run(debug=True)
